package com.lc.railway.ui.fragment;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lc.railway.R;
import com.lc.railway.app.AppFragment;
import com.lc.railway.bean.DataBean;
import com.lc.railway.ui.adapter.TopLineAdapter;
import com.lc.railway.util.constant.EvenConstant;
import com.lc.railway.util.eventbus.Event;
import com.lc.railway.util.eventbus.EventBusUtils;
import com.youth.banner.Banner;
import com.youth.banner.transformer.ZoomOutPageTransformer;
import com.youth.banner.util.LogUtils;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;

public class ImportantNewsFragment extends AppFragment {
    @BindView(R.id.banner)
    Banner banner;
    @BindView(R.id.banner_hot)
    Banner bannerHot;
    @BindView(R.id.rv_importantnews)
    RecyclerView rvImportantnews;
    @BindView(R.id.rv_album)
    RecyclerView rvAlbum;
    @BindView(R.id.rv_higherups)
    RecyclerView rvHigherups;
    List<String> invirstList=new ArrayList<>();
    private BaseQuickAdapter<String, BaseViewHolder> importantnewsAdapter;
    private BaseQuickAdapter<String, BaseViewHolder> albumAdapter;
    private BaseQuickAdapter<String, BaseViewHolder> higherupsAdapter;
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_importantnews;
    }

    @Override
    protected void initView() {




        bannerHot.setAdapter(new TopLineAdapter(DataBean.getTestData2()))
                .setOrientation(Banner.VERTICAL)
                .setPageTransformer(new ZoomOutPageTransformer())
                .setOnBannerListener((data, position) -> {
                   
                    LogUtils.d("position：" + position);
                });
        for (int i = 0; i < 2; i++) {
            invirstList.add(i+"");

        }
     ;
        importantnewsAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_importantnews,invirstList) {
            @Override
            protected void convert(@NotNull BaseViewHolder holder, String s) {
                holder.setText(R.id.tv_title,"习近平：在“不忘初心、牢记使命”主题教育总结大会上的讲话"+s);
            }
        };
        rvImportantnews.setAdapter(importantnewsAdapter);

        albumAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_importantnews,invirstList) {
            @Override
            protected void convert(@NotNull BaseViewHolder holder, String s) {
                holder.setText(R.id.tv_title,"习近平：在“不忘初心、牢记使命”主题教育总结大会上的讲话"+s);
            }
        };
        rvAlbum.setAdapter(albumAdapter);

        higherupsAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_importantnews,invirstList) {
            @Override
            protected void convert(@NotNull BaseViewHolder holder, String s) {
                holder.setText(R.id.tv_title,"习近平：在“不忘初心、牢记使命”主题教育总结大会上的讲话"+s);
            }
        };
        rvHigherups.setAdapter(higherupsAdapter);
    }

    @Override
    protected void initData() {

    }

    @OnClick({R.id.sb_product, R.id.sb_Album,R.id.sb_higherups})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.sb_product:

                EventBusUtils.sendEvent(new Event(EvenConstant.SHOP_ACTIVITY_TAB_ZERO, 1));
                break;

            case R.id.sb_Album:
                EventBusUtils.sendEvent(new Event(EvenConstant.SHOP_ACTIVITY_TAB_ONE, 1));
                break;
            case R.id.sb_higherups:
                EventBusUtils.sendEvent(new Event(EvenConstant.SHOP_ACTIVITY_TAB_TWO, 1));
                break;
        }
    }
}
